package main

import (
	"fmt"
	"strings"
	"strconv"
	"os"
)

type person struct {
	name string
	sex  byte
	age  int
}

func (p *person) printInfo() {
	fmt.Printf("person: %#v\n", p)
}

type student struct {
	person
	id   int
	addr string
}

func main() {
	if 1 != len(os.Args) {
		if len(os.Args) < 2 {
			os.Exit(1)
		}
		textQuoted := strconv.QuoteToASCII(os.Args[1])
		textUnquoted := textQuoted[1 : len(textQuoted)-1]
		fmt.Println(textUnquoted)
		if len(os.Args) < 3 {
			os.Exit(1)
		}
		sUnicode := strings.Split(os.Args[2], "\\u")
		var raw string
		for i := range sUnicode {

			if len(sUnicode[i]) <= 1 {
				continue
			}
			if char, err := strconv.ParseInt(sUnicode[i], 16, 64); nil == err {
				raw += fmt.Sprintf("%c", char)
			}
		}
		fmt.Println(raw)
		os.Exit(0)
	}

	stu := student{person{"zhangsan", 'm', 18}, 1, "hz"}
	stu.printInfo()
	pp := (*student).printInfo
	pp(&stu)

	fmt.Println(strings.Replace("bsb", "b", "c", 0))


	s := make([]byte, 0, 1024)
	s = strconv.AppendBool(s, true)
	s = strconv.AppendInt(s, 1234, 10)
	s = strconv.AppendQuote(s, "hello")
	fmt.Printf("%#v\n", string(s))
}
